package com.qmth;

import com.qmth.dao.JpaDao;
import com.qmth.entity.Student;
import com.qmth.mapper.StudentMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.orm.jpa.EntityScan;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 程序运行入口
 */
@RestController
@ComponentScan
@EntityScan
@EnableAutoConfiguration
public class Application {

    @Autowired(required = true) private StudentMapper stuMapper;
    @Autowired private JpaDao jpaDao;

    @RequestMapping("/{id}")
    public String Hello(@PathVariable String id) {
        Student stu = stuMapper.getStudent(id);
        String name = stu != null ? stu.getName() : "";
        Integer cnt = jpaDao.getStudent();
        System.err.println(cnt);
        return "Hello QMTH！";
    }

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
        System.out.println("程序启动完毕！");
    }
}
